var e = require;
var t = module;
var o = exports;
var n,
    i = o,
    a =
        ((n = function (e, t) {
            return (n =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (e, t) {
                        e.__proto__ = t;
                    }) ||
                function (e, t) {
                    for (var o in t) t.hasOwnProperty(o) && (e[o] = t[o]);
                })(e, t);
        }),
        function (e, t) {
            function o() {
                this.constructor = e;
            }
            n(e, t), (e.prototype = null === t ? Object.create(t) : ((o.prototype = t.prototype), new o()));
        }),
    r = function (e, t, o, n) {
        var i,
            a = arguments.length,
            r = a < 3 ? t : null === n ? (n = Object.getOwnPropertyDescriptor(t, o)) : n;
        if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(e, t, o, n);
        else
            for (var s = e.length - 1; s >= 0; s--)
                (i = e[s]) && (r = (a < 3 ? i(r) : a > 3 ? i(t, o, r) : i(t, o)) || r);
        return a > 3 && r && Object.defineProperty(t, o, r), r;
    };
Object.defineProperty(i, "__esModule", {value: !0}), (i.ToastModel = void 0);
var s,
    c,
    l = e("AssetsMap"),
    d = e("BundleNames"),
    u = e("GameData"),
    p = e("view_killToast");
((c = s || (s = {})).zero = "一血"),
    (c.one = "单杀"),
    (c.two = "双杀"),
    (c.three = "三杀"),
    (c.four = "四杀"),
    (c.five = "五杀"),
    (c.six = "六杀"),
    (c.seven = "七杀"),
    (c.eight = "八杀");
var h = function () {
    this.killType = s.one;
};
i.ToastModel = h;
var f = cc._decorator,
    _ = f.ccclass,
    y = f.property,
    m = (function (e) {
        function t() {
            var t = (null !== e && e.apply(this, arguments)) || this;
            return (
                (t.view_killToast = null),
                (t.onceKill = !1),
                (t.toastList = []),
                (t.itemModel = []),
                (t._label_surplusSnake_num = 0),
                (t._label_userKill_num = 0),
                t
            );
        }
        return (
            a(t, e),
            (t.prototype.refreshSnakeKillData = function (e, t) {
                if ((this.refreshKillTip(e, t), e.snakeName == u.default.instance.UserName))
                    (this.label_userKill_num = 0), (this.toastList = []);
                else if (t.snakeName == u.default.instance.UserName) {
                    this.label_userKill_num++,
                        ((n = new h()).self_snakeName = e.snakeName),
                        (n.other_snakeName = t.snakeName);
                    var o = this.label_userKill_num;
                    1 == o
                        ? (n.killType = s.one)
                        : 2 == o
                        ? (n.killType = s.two)
                        : 3 == o
                        ? (n.killType = s.three)
                        : 4 == o
                        ? (n.killType = s.four)
                        : 5 == o
                        ? (n.killType = s.five)
                        : 6 == o
                        ? (n.killType = s.six)
                        : 7 == o
                        ? (n.killType = s.seven)
                        : o >= 8 && (n.killType = s.eight),
                        this.onceKill || n.killType != s.one || (n.killType = s.zero),
                        n.killType != s.one && this.toastList.push(n),
                        1 == this.toastList.length && this.showToastAni();
                } else {
                    var n;
                    this.onceKill ||
                        ((this.onceKill = !0),
                        ((n = new h()).killType = s.zero),
                        (n.self_snakeName = e.snakeName),
                        (n.other_snakeName = t.snakeName),
                        this.toastList.push(n),
                        1 == this.toastList.length && this.showToastAni());
                }
            }),
            (t.prototype.showToastAni = function () {
                var e = this;
                if (0 != this.toastList.length) {
                    var t = this.toastList.shift(),
                        o = "kill_";
                    if (t.killType == s.zero || t.killType == s.one) o += 1;
                    else if (t.killType == s.two) o += 2;
                    else if (t.killType == s.three) o += 3;
                    else if (t.killType == s.four) o += 4;
                    else if (t.killType == s.five) o += 5;
                    else if (t.killType == s.six) o += 6;
                    else if (t.killType == s.seven) o += 7;
                    else {
                        if (t.killType != s.eight) return void this.showToastAni();
                        o += 8;
                    }
                    this.view_killToast.playAni(t);
                    var n = game.BundleManager.instance
                        .getBundle(d.default.Game)
                        .get(l.default.GameBundle.sounds.assetsList[o], cc.AudioClip);
                    game.AudioManager.playEffect(n),
                        this.scheduleOnce(function () {
                            e.showToastAni();
                        }, 2);
                }
            }),
            (t.prototype.refreshKillTip = function (e, t) {
                var o = this.node.getChildByName("scrollView").getComponent(cc.ScrollView).content,
                    n = new h();
                (n.other_snakeName = e.snakeName), (n.self_snakeName = t.snakeName), this.itemModel.unshift(n);
                for (var i = 0; i < 3; i++)
                    this.itemModel.length <= i
                        ? (o.children[i].active = !1)
                        : ((o.children[i].active = !0),
                          (o.children[i].getComponent(cc.Label).string =
                              this.itemModel[i].self_snakeName + "击杀了" + this.itemModel[i].other_snakeName));
            }),
            Object.defineProperty(t.prototype, "label_surplusSnake_num", {
                get: function () {
                    return this._label_surplusSnake_num;
                },
                set: function (e) {
                    (this._label_surplusSnake_num = e), this.refreshKillData();
                },
                enumerable: !1,
                configurable: !0
            }),
            Object.defineProperty(t.prototype, "label_userKill_num", {
                get: function () {
                    return this._label_userKill_num;
                },
                set: function (e) {
                    (this._label_userKill_num = e), this.refreshKillData();
                },
                enumerable: !1,
                configurable: !0
            }),
            (t.prototype.refreshKillData = function () {
                this.node.active &&
                    ((this.node
                        .getChildByName("kill_data")
                        .getChildByName("label_surplusSnake_num")
                        .getComponent(cc.Label).string = this.label_surplusSnake_num.toString()),
                    (this.node
                        .getChildByName("kill_data")
                        .getChildByName("label_userKill_num")
                        .getComponent(cc.Label).string = this.label_userKill_num.toString()));
            }),
            r([y(p.default)], t.prototype, "view_killToast", void 0),
            r([_], t)
        );
    })(cc.Component);
i.default = m;
